<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
    <title>历史访客记录列表</title>
    <script src="${pageContext.request.contextPath}/static/jquery/jquery-3.1.1.js"></script>
    <script src="${pageContext.request.contextPath}/static/jquery/jquery.validate.js"></script>
    <link rel="stylesheet" href="/static/frame/layui/css/layui.css">
    <link rel="stylesheet" href="/static/frame/static/css/style.css">
    <link rel="icon" href="/static/frame/static/image/code.png">
</head>
<body>
<div style="margin-top: 10px;margin-left: 10px">注：1、无输入查询即为查询全部；2、访客查询为查询含有查询值的所有访客名，故查询结果可能为多个；3、日期查询为查询某一天全天的访客记录</div>
<div>
    <form action="/visitorListAllByVisitor.do" method="post" style="float: left;margin-right: 20px;margin-top: 5px;margin-bottom: 5px;margin-left: 5px">
        <input type="text" name="visitor_name" style="height: 40px;padding-left:5px;font-size: 16px" class="selectbox" placeholder="访客姓名 / Name"/>
        <input type="submit" style="padding-top: 7px;padding-bottom: 9px" value="查询访客姓名" class="selectbutton"/>
    </form>
    <form action="/visitorListAllByUser.do" method="post"  style="float:left;margin-left:20px;margin-top: 5px;margin-bottom:5px">
        <input type="text" name="visitor_user_name" style="height: 40px;padding-left:5px;font-size: 16px" class="selectbox" placeholder="用户姓名 / Name"/>
        <input type="submit" style="padding-top: 7px;padding-bottom: 9px" value="查询用户姓名" class="selectbutton"/>
    </form>
    <form action="/visitorListAllByDate.do" method="post"  style="height: 42px;float:left;margin-left:20px;margin-top: 5px;">
        <div class="layui-form-item">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" style="height: 40px;padding-left:5px;font-size: 16px"  name="visitor_arrivaltime" id="date" lay-verify="date" placeholder="查询日期" autocomplete="off" class="layui-input">
                </div>
                <input type="submit" style="padding-top: 6px;padding-bottom: 8px;padding-left: 15px;padding-right: 15px" value="查询" class="selectbutton"/>
            </div>
        </div>
    </form>
</div>

    <div class="showmessages">
        <table class="layui-table">
            <thead>
            <tr>
                <th style="width: 40px;">访客记录ID</th>
                <th style="width: 100px;">访客姓名</th>
                <th style="width: 40px;">访客人数</th>
                <th style="width: 60px;">所属用户姓名</th>
                <th style="width: 60px;">用户住所</th>
                <th style="width: 100px;">报备时间</th>
                <th style="width: 100px;">预计到访时间</th>
                <th style="width: 40px;">到访状态</th>
                <th style="width: 100px;">到访时间</th>
                <th style="width: 40px;">记录人</th>
            </tr>
            </thead>
            <tbody id="clear" style="display: none">
            <script>var arr1=[]</script>
            <c:if test="${not empty sessionScope.visitorAllList}">
            <c:forEach items="${sessionScope.visitorAllList}" var="o" varStatus="loop">
                <tr id="visorder${loop.count}">
                    <td>${loop.count}</td>
                    <td>${o.getVisitor_name()}</td>
                    <td>${o.getVisitor_number()}</td>
                    <td>${sessionScope.visitorAllUserList[loop.count-1].user_name}</td>
                    <td>${sessionScope.visitorAllHostList[loop.count-1].host_building}栋${sessionScope.visitorAllHostList[loop.count-1].host_unit}单元${sessionScope.visitorAllHostList[loop.count-1].host_housenumber}号</td>
                    <td class="createtime">${o.getVisitor_createtime()}</td>
                    <td class="visitetime">${o.getVisitor_time()}</td>
                    <c:if test="${o.getVisitor_status()==0}"><td style="color: red">未到访</td></c:if>
                    <c:if test="${o.getVisitor_status()!=0}"><td style="color: #00C0F7">已到访</td></c:if>
                    <c:if test="${o.getVisitor_arrivaltime()!=null}"><td class="arrivaltime">${o.getVisitor_arrivaltime()}</td></c:if>
                    <c:if test="${o.getVisitor_arrivaltime()==null}"><td></td></c:if>
                    <c:if test="${o.getVisitor_admin_id()==-1}"><td>未到访</td></c:if>
                    <c:if test="${o.getVisitor_admin_id()!=-1}"><td>${visitorAllAdminList[loop.count-1].admin_name}</td></c:if>
                </tr>
                <script>arr1.push($("#visorder${loop.count}")[0])</script>
            </c:forEach>
            </c:if>
            </tbody>
            <tbody id="biuuu_city_list"></tbody>
        </table>
        <div id="demo20"></div>
    </div>
</body>
<script src="${pageContext.request.contextPath}/static/frame/layui/layui.js" charset="utf-8"></script>
<script>
    function nodeToString ( node ) {
        var tmpNode = document.createElement( "div" );
        tmpNode.appendChild( node.cloneNode( true ) );
        var str = tmpNode.innerHTML;
        tmpNode = node = null; // prevent memory leaks in IE
        return str;
    }
    function clear(){
        document.getElementById('clear').innerHTML=null;
    }

    layui.use(['carousel', 'laypage','laydate','form','upload','jquery'], function(){
        var carousel = layui.carousel
            ,form = layui.form
            ,$=layui.jquery
            ,upload = layui.upload
            ,laypage = layui.laypage
            ,laydate = layui.laydate

        //常规轮播
        carousel.render({
            elem: '#test1'
            ,arrow: 'always'
        });
        var data1= arr1;
        laypage.render({
            elem: 'demo20'
            ,count: data1.length
            ,jump: function(obj){
                //模拟渲染
                document.getElementById('biuuu_city_list').innerHTML = function(){
                    var arr = []
                        ,thisData = data1.concat().splice(obj.curr*obj.limit - obj.limit, obj.limit);
                    layui.each(thisData, function(index, item){
                        var itemstr=nodeToString(item);
                        arr.push(itemstr);
                    });
                    clear();
                    return arr.join('');
                }();
            }
        });
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1'
        });

    });
</script>
<script>
    var w=$(window).width();
    var h=$(window).height();
    $(".pageall").innerHeight(h+"px");
    $(".pageall").innerWidth(w+"px");
    /**
     * 时间显示，调整格式
     */
    showtime();
    function showtime() {
        var createtime=$(".createtime");
        var visitetime=$(".visitetime");
        var arrivaltime=$(".arrivaltime");
        createtime.each(function () {
            //调用时间格式转换函数formatDateTime()
            $(this).text(formatDateTime($(this).text()))
        });
        visitetime.each(function () {
            //调用时间格式转换函数formatDateTime()
            $(this).text(formatDateTime($(this).text()))
        });
        arrivaltime.each(function () {
            //调用时间格式转换函数formatDateTime()
            $(this).text(formatDateTime($(this).text()))
        })
    }
    /**
     *
     * 在页面上，转换时间格式
     * @param inputTime
     * @returns {string}
     */
    function formatDateTime(inputTime) {
        var date = new Date(inputTime);
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? ('0' + m) : m;
        var d = date.getDate();
        d = d < 10 ? ('0' + d) : d;
        var h = date.getHours();
        h = h < 10 ? ('0' + h) : h;
        var minute = date.getMinutes();
        var second = date.getSeconds();
        minute = minute < 10 ? ('0' + minute) : minute;
        second = second < 10 ? ('0' + second) : second;
        return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;
    };
</script>
</html>